//创建FeatureLayer要素图层
var targetLayer = mapManager.createFeatureLayer($("#targetLayer").combobox("getValue"));
var targetFeatures = null;
//存储饼状图展示数据
var overlayArray = [];
//存储各个类型名称和数量
var dataName = [];
//存储各个类型下的数据
var arrayAll = new Array();
//查询要素图层得到所有要素集
targetLayer.queryFeatures().then(function(results){
    targetFeatures = results.features;
    global.currentQueryUrl = $("#joinLayer").combobox("getValue");
    //创建FeatureLayer要素图层
    var joinLayer = mapManager.createFeatureLayer(global.currentQueryUrl);
    //查询要素图层得到所有要素集
    joinLayer.queryFeatures().then(function(results){
        featureArray = results.features;
        for(var i=0; i<targetFeatures.length; i++){
            var count = 0;
            var array = new Array();
            for(var j=0; j<featureArray.length; j++){
                //循环判断2个图形是否重叠，如果重叠则记录在数值里
                if(geometryEngine.contains(targetFeatures[i].geometry,featureArray[j].geometry)){
                    count++;
                    featureArray[j].attributes.id = featureArray[j].attributes.ID;
                    array.push(featureArray[j].attributes);
                }
            }
            arrayAll.push(array);
            overlayArray.push({"name":targetFeatures[i].attributes.NAME+"："+count,"value":count});
            dataName.push({"name":targetFeatures[i].attributes.NAME,"count":count});
        }
        $("#contentBox").html("<hr><div id=\"overlayPie\" style=\"width:360px;height:300px;\" align=\"center\"></div><div id=\"overlayResultDg\" data-options=\"width:360,striped:true\"></div>");
        overlayAnalysis.pieResult(overlayArray);
        overlayAnalysis.overlayDg(dataName,arrayAll);
    });
});